package game.state.menu;

import engine.Displays;
import engine.input.Mouse;
import engine.render.buffer.TriBuffer;
import engine.render.type.Tri;
import engine.res.Color;
import engine.res.Res;
import game.Game;
import game.state.GameState;
import game.state.menu.ui.Button;
import libRender.Quad;

public class TitleMenu extends GameState 
{
    
    private Button start;
//    private Button options;
    private Button quit;
    
    public TitleMenu(Displays _display) 
    {
        super(_display);
        start = new Button(getScaledX(140), getScaledY(634), getScaledX(766), getScaledY(750));
//        options = new Button(getScaledX(140), getScaledY(440), getScaledX(766), getScaledY(556));
        quit = new Button(getScaledX(140), getScaledY(249), getScaledX(766), getScaledY(365));
    }
    
    public void update(Mouse mouse, TriBuffer dim2) 
    {
        if (quit.wasPressedBy(mouse)) 
        {
            Game.stopRunning();
        }
        if (start.wasPressedBy(mouse)) 
        {
            movingOn = GameState.GAMEPLAY;
        }
        dim2.triangles(getRender());
    }
    
    private Tri[] getRender() 
    {
        float w = display.currentW();
        float h = display.currentH();
        Tri[] quad = Quad.gen().get(
                0, 0, -0.3f, 0, 0, 
                w, 0, -0.3f, 1, 0, 
                w, h, -0.3f, 1, 1, 
                0, h, -0.3f, 0, 1, 
                0, 0, 1, 
                Color.WHITE, 
                Res.loader().getTex("title")
        );
        return quad;
    }
    
}